﻿using System;
using System.Collections.Generic;
using System.Reflection;
using BGShell.Components;
using BGShell.Drawing;

namespace BGShell.PowerShell.DataTips
{
    internal class StaticMembersDataTip : PSObjectRawDataTip
    {
        public StaticMembersDataTip(Type type)
            : base(Resources.ReflectionDataTipStaticMembers, null, false, type)
        {
            Icon = TypeModelIcon.Class;
            IconOverlay = TypeModelIconOverlay.Static;
        }

        public override string ValueAsString
        {
            get { return string.Empty; }
        }

        protected override IEnumerable<DataTipItem> AppendSubItems()
        {
            return NoItems;
        }

        protected override BindingFlags GetBindingFlags()
        {
            return BindingFlags.Public | BindingFlags.Static;
        }

        protected override PSObjectRawDataTip Create(Object target, FieldInfo field)
        {
            if (ValueType.IsEnum)
            {
                return new PSObjectRawDataTip(field.Name, field.GetValue(target));
            }

            return base.Create(target, field);
        }

        protected override bool IsPrimitiveType(Type t)
        {
            return (t == null);
        }
    }
}
